package com.net.sorting;

public class BinaryTest {

	public static void main(String[] args) 
	{
		int binary[] = {4,1,3,6,8,34,56,77,33};
		
		int first = 0;
		int last = binary.length-1;
		
		int middle = (first + last)/2;
		
		System.out.println(middle);
		
		int search = 77;
		
		System.out.println(binary[middle]);
		
		
		
		while(first<= last)
		{
			if(binary[middle]<search)
			{
				first = middle+1;
			}
			else if(binary[middle] == search)
			{
				System.out.println("search found at  position " +(middle+1)+  "  number   "+ search );
				break;
			}
			else 
			{
				last = middle-1;
			}
			
			middle = (first+last)/2;
		}

	}

}
